package com.sunny.ynhz.adapter.mine;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sunny.ynhz.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/7/15/015.
 */

public class MysignedAdapater extends RecyclerView.Adapter<MysignedAdapater.DataHolder> {
    Context context;
    List<String> mdata;

    public MysignedAdapater(Context context, List<String> mdata) {
        this.context = context;
        this.mdata=mdata;
    }

    @Override
    public DataHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_signed,null);
        DataHolder dataHolder=new DataHolder(view);
        return dataHolder;
    }

    @Override
    public void onBindViewHolder(DataHolder holder, int position) {
        String sValue = mdata.get(position);
        if(TextUtils.isEmpty(sValue)){
            holder.iv_day.setVisibility(View.INVISIBLE);
            holder.tv_week_day.setText(sValue);
        }
        else {
            holder.tv_week_day.setText(sValue);
            holder.iv_day.setVisibility(View.VISIBLE);
        }
        if(position==15){
            holder.iv_day.setVisibility(View.GONE);
            holder.tv_week_day.setTextColor(Color.parseColor("#fe3a5b"));
            holder.img_error.setVisibility(View.VISIBLE);

        }
        else {
            holder.tv_week_day.setTextColor(Color.BLACK);
            holder.img_error.setVisibility(View.GONE);
            holder.iv_day.setVisibility(View.VISIBLE);
        }
        if(position>15){
            holder.img_error.setVisibility(View.GONE);
            holder.iv_day.setVisibility(View.INVISIBLE);
            holder.tv_week_day.setTextColor(Color.parseColor("#666666"));

        }

    }

    @Override
    public int getItemCount() {
        return mdata.size();
    }

    class DataHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_week_day)
        TextView tv_week_day;
        @BindView(R.id.iv_day)
        ImageView iv_day;
        @BindView(R.id.img_error)
        View img_error;
        public DataHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

}
